package com.zj.controller;

import com.zj.controller.model.ResponseResult;
import com.zj.po.HostInfoPO;
import com.zj.service.HostInfoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hosts")    //   url前缘: http://localhost:8080/hosts/
public class HostInfoController {

    @Autowired
    private HostInfoService hostInfoService;

    @GetMapping("/list")
    public ResponseResult findHostInfoList(){
        List<HostInfoPO> list=this.hostInfoService.findHostInfoList();
        return ResponseResult.ok().setData( list );
    }

    @GetMapping("/{host}")  //路径参数
    public ResponseResult findHostInfo( @PathVariable("host")  String host){
        List<HostInfoPO> list=this.hostInfoService.findHostInfo( host );  //查询host主机出最近的100条信息
        return ResponseResult.ok().setData( list );
    }
}